/*!
 * express
 * Copyright(c) 2009-2013 TJ Holowaychuk
 * Copyright(c) 2013 Roman Shtylman
 * Copyright(c) 2014-2015 Douglas Christopher Wilson
 * MIT Licensed
 */

'use strict';

//是一个函数，并添加了一些静态属性
var express =require('./lib/express');
// console.log(typeof express);
//console.log(Object.keys(express))

//执行时创建一个app函数，
//并通过mixin添加emitter 实现on emit 功能 ，添加application 
//然后执行application.init 最后返回app  
const app = express();

// console.log(Object.keys(app))
console.log(typeof app);
app.get('/',function(req,res,next){
    //console.log(req.query,next.toString())
    console.log('app.get / 1' )
    //console.log(app._router.stack)    
    app._router.stack.forEach(function(i){
        if(i.path=='/'){
            console.log(i,i.route.stack[0])
            console.log('cc'    );
        }
    })
    next();
})
app.get('/',function(req,res,next){
    console.log('app.get / 2')
    res.send({name:'star'});
})
//此方法创建Router 实例//
//console.log(app.lazyrouter)
console.log(app._router.stack)
app.listen(3004,function(){
    console.log('listen 3004')
})

// var id=0;
// while(id<3){
//     id+=1;
//     console.log(id);
//     if(id==1){
//         continue;
//     }
//     console.log('id',id)
// }
// console.log('cc',id);



// var mixin = require('merge-descriptors');
// var u={};
// var EventEmitter = require('events').EventEmitter;
// mixin(u,EventEmitter.prototype,false);
// console.log(u); 
// u.on('up',function(){
//     console.log('up')
// })
// u.emit('up')

// var resolve = require('path').resolve;
// console.log(resolve('views'))
// console.log(resolve('../','cc/'))


